package mall.servlet;

import mall.bean.Product;

/**
 * 后端返回给前端的通用结果
 * 
 * @author Administrator
 *
 */
public class Result {
	private int code;
	private String msg;
	private Object data;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Result() {
	}

	public Result(int code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static Result success() {
		return success("SUCCESS");
	}

	public static Result success(String msg) {
		return success(0, msg);
	}

	public static Result success(int code, String msg) {
		return build(code, msg, null);
	}
	
	public static Result success(Object data) {
		return build(0, "SUCCESS", data);
	}

	public static Result error() {
		return error("ERROR");
	}

	public static Result error(String msg) {
		return error(1, msg);
	}

	public static Result error(int code, String msg) {
		return build(code, msg, null);
	}

	public static Result build(int code, String msg, Object data) {
		return new Result(code, msg, data);
	}

	

}
